<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
    <style>
      .card {
        width: 10rem;
      }

      /* Anything bellow here isn't necessary, it's only for the demo */

      .card {
        background-color: #f25d9c;
      }

      /* Set some height to cards */
      .card:nth-child(1) {
        height: 240px;
      }

      .card:nth-child(2) {
        height: 190px;
      }

      .card:nth-child(3) {
        height: 210px;
      }

      .card:nth-child(4) {
        height: 230px;
      }

      .card:nth-child(5) {
        height: 180px;
      }

      .card:nth-child(6) {
        height: 200px;
      }

      body {
        background-color: #f9f7f7;
      }

      .cards {
        width: 100%;
        max-width: 1040px;
        margin: 0 auto;
        text-align: center;
      }
    </style>
  </head>
  <body>
    <div class="cards">
      <div class="card"></div>
      <div class="card"></div>
      <div class="card"></div>
      <div class="card"></div>
      <div class="card"></div>
      <div class="card"></div>
    </div>
    <script src="https://npmcdn.com/minigrid@3.0.1/dist/minigrid.min.js"></script>
    <script>
      ;(function() {
        var grid
        function init() {
          grid = new Minigrid({
            container: '.cards',
            item: '.card',
            gutter: 12
          })
          grid.mount()
        }

        // mount
        function update() {
          grid.mount()
        }

        document.addEventListener('DOMContentLoaded', init)
        window.addEventListener('resize', update)
      })()
    </script>
  </body>
</html>
